function node2Object(node)
{
	var res = new Object();
	for(var i=0; i<node.childNodes.length; i++)
	{
		res[node.childNodes[i].nodeName] = node.childNodes[i];
	}
	return res;
}

function callback__MODULE_ID__(datadom)
{
		var entries = new Array();
		var k = 0;
		
		var items = datadom.getElementsByTagName("item");
		for(i=0; i<items.length; i++)
		{
			var node = node2Object(items[i]);
			var titel = node.title.firstChild.nodeValue;
			var img = (node.enclosure!=null)?node.enclosure.getAttribute("url"):"http://www.tvmovie.de/fileadmin/img/default/tvm_default_blau_80x60.jpg";
			entries.push({"titel":titel,"img":img});
		}
		
		entries = entries.select(sender__MODULE_ID__);
		
		var t = "<TABLE CELLSPACING=0 CELLPADDING=0 WIDTH='100%'>";
		for(var i=0; i<entries.length; i++)
		{
			t += "<tr>";
			t += "<td><img src='"+entries[i].img+"'></img></td>";
			t += "<td>"+entries[i].titel+"</td>";
			t += "</tr>";
		}
		
		t += "</TABLE>";

		_gel("tvmovie__MODULE_ID__").innerHTML = t;
		_IG_AdjustIFrameHeight();
}
Array.prototype.select = function(/*RegExp*/ regexp)
{
	var result = new Array();
	for(var i=0; i<this.length; i++){
		var el = this[i];
		if (regexp.test(el.titel))
			result.push(el);
	}
	return result;
}

var sender__MODULE_ID__ = null;
function updateTVMOVIE__MODULE_ID__()
{
	var prefs = new _IG_Prefs(__MODULE_ID__);
	var feedurl = prefs.getString("XML_FEED");
	sender__MODULE_ID__ = new RegExp("^\\d\\d:\\d\\d\\s+"+prefs.getString("SENDER"));
	
	_IG_FetchXmlContent(feedurl,callback__MODULE_ID__);
}

_IG_RegisterOnloadHandler(updateTVMOVIE__MODULE_ID__);
